package bTree.LeetCode;

public class 验证二叉搜索树 {
    long pre=Long.MIN_VALUE;
    public boolean isValidBST(TreeNode root) {
        if (null==root){
            return true;
        }
        boolean left =isValidBST(root.left);
        if (!left) return false;
        if (root.val<=pre) return false;
        pre=root.val;
        boolean right =isValidBST(root.right);
        if (!right) return false;
        return true;
    }
}